﻿
@{
    Layout = null;
}



<link href="~/libs/layui-v2.9.21/layui-v2.9.21/layui/css/layui.css" rel="stylesheet" />

<form class="layui-form" action="">
    <div class="layui-form-item">
        <label class="layui-form-label">创建人姓名</label>
        <div class="layui-input-inline layui-input-wrap">
            <input type="text" id="creatorName" name="creatorName" lay-verify="required" autocomplete="off" lay-affix="clear" class="layui-input" placeholder="请输入创建人姓名">
        </div>
    </div>
    <div class="layui-inline">
        <label class="layui-form-label">创建日期</label>
        <div class="layui-input-inline layui-input-wrap">
            <div class="layui-input-prefix">
                <i class="layui-icon layui-icon-date"></i>
            </div>
            <input type="text" name="creationDate" id="creationDate" lay-verify="date" placeholder="请输入创建日期" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">出货单号</label>
        <div class="layui-input-inline layui-input-wrap">
            <input type="text" id="shipmentNumber" name="shipmentNumber" lay-verify="required" autocomplete="off" lay-affix="clear" class="layui-input" placeholder="请输入出货单号">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">货主编码</label>
        <div class="layui-input-inline layui-input-wrap">
            <input type="text" id="productCode" name="productCode" lay-verify="required" autocomplete="off" lay-affix="clear" class="layui-input" placeholder="请输入货主编码">
        </div>
    </div>
    <div class="layui-inline">
        <label class="layui-form-label">要求交货时间</label>
        <div class="layui-input-inline layui-input-wrap">
            <div class="layui-input-prefix">
                <i class="layui-icon layui-icon-date"></i>
            </div>
            <input type="text" name="requiredDeliveryTime" id="requiredDeliveryTime" lay-verify="date" placeholder="请输入要求交货时间" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">收货人姓名</label>
        <div class="layui-input-inline layui-input-wrap">
            <input type="text" id="receiver" name="receiver" lay-verify="required" autocomplete="off" lay-affix="clear" class="layui-input" placeholder="请输入收货人姓名">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">收货人电话</label>
        <div class="layui-input-inline layui-input-wrap">
            <input type="text" id="receiverPhone" name="receiverPhone" lay-verify="required" autocomplete="off" lay-affix="clear" class="layui-input" placeholder="请输入收货人电话">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">收货人地址</label>
        <div class="layui-input-inline layui-input-wrap">
            <input type="text" id="receiverAddress" name="receiverAddress" lay-verify="required" autocomplete="off" lay-affix="clear" class="layui-input" placeholder="请输入收货人地址">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">运输公司</label>
        <div class="layui-input-inline layui-input-wrap">
            <input type="text" id="transportCompany" name="transportCompany" lay-verify="required" autocomplete="off" lay-affix="clear" class="layui-input" placeholder="请输入运输公司">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">发货运单号</label>
        <div class="layui-input-inline layui-input-wrap">
            <input type="text" id="shipmentOrderNumber" name="shipmentOrderNumber" lay-verify="required" autocomplete="off" lay-affix="clear" class="layui-input" placeholder="请输入发货运单号">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">发货备注</label>
        <div class="layui-input-block">
            <textarea placeholder="请输入发货备注" id="shipmentNotes" name="shipmentNotes" class="layui-textarea"></textarea>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">当前状态</label>
        <div class="layui-input-inline layui-input-wrap">
            <input type="text" id="status" name="status" lay-verify="required" autocomplete="off" lay-affix="clear" class="layui-input" placeholder="请输入当前状态">
        </div>
    </div>
    <div class="layui-form-item">
        <div class="layui-input-block">
            <button type="submit" class="layui-btn" lay-submit lay-filter="add">确定</button>
            <button type="reset" class="layui-btn layui-btn-primary"  onclick="closeWorkStation()">关闭</button>
        </div>
    </div>
</form>

<!-- 请勿在项目正式环境中引用该 layui.js 地址 -->
<script src="~/libs/jquery/jquery.js"></script>
<script src="~/libs/layui-v2.9.21/layui-v2.9.21/layui/layui.js"></script>
<script>
        //关闭弹框
        function closeWorkStation() {
            var index = parent.layer.getFrameIndex(window.name);//先得到当前的索引
            parent.layer.close(index);//再执行关闭
        }
layui.use(['form', 'laydate', 'util'], function(){
  var form = layui.form;
  var layer = layui.layer;
  var laydate = layui.laydate;
  var util = layui.util;


  // 提交事件
  form.on('submit(add)', function(data){
      var field = data.field; // 获取表单字段值
      console.log(field)
    // 显示填写结果，仅作演示用
    layer.alert(JSON.stringify(field), {
      title: '当前填写的字段值'
    });
    // 此处可执行 Ajax 等操作
      $.ajax({
          type: 'post',
          url: '/CustomerShipment/AddCustomerShipment',
          dataType: 'json',
          data:field,
          success: function (res) {
              if (res > 0) {
                  layer.msg('添加成功')
                  closeWorkStation()
                  return false;
              }
              if (res == -1) {
                  layer.msg('出货单号已存在')
                  return false;
              }
              if (res == -2) {
                  layer.msg('仓库编码已存在')
                  return false;
              }
          }
      })
    return false; // 阻止默认 form 跳转
  });

    // 日期
    laydate.render({
        elem: '#creationDate',
    });
    // 日期
    laydate.render({
        elem: '#requiredDeliveryTime',
    });
});
</script>
